package com.soup.lab.basic.map;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class MapTestCase {

    @Test
    public void testHashMap() {
        Map map = new HashMap();
        map.put("a", null);
        map.put(null, "b");
        Assertions.assertTrue(map.containsKey("a"));
        Assertions.assertTrue(map.containsKey(null));
        Assertions.assertTrue(map.containsValue(null));

    }

    @Test
    public void testConcurrentHashMap() {
        Map map = new ConcurrentHashMap();
        Assertions.assertThrows(NullPointerException.class, () -> {
            map.put("a", null);
        });
        Assertions.assertThrows(NullPointerException.class, () -> {
            map.put(null, "b");
        });
    }

}
